package com.heying.springcore.aop.transaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.SQLException;

@Component
public class UserService {

    private UserDao userDao ;

    public UserService(@Autowired UserDao userDao){
        this.userDao = userDao;
    }



    /**
     * 一次性添加两个用户
     * 要不一起成功，要不一起失败
     * @param user1
     * @param user2
     */

    public void addTwoUsers(UserInfo user1,UserInfo user2) throws SQLException {
        userDao.insertOne(user1);
        userDao.insertOne(user2);
    }

}
